<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="org.limp.mine.StringTool"%>
<%@ page import="org.limp.mine.DateTrimmer"%>
<%@ page import="jt.classic.system.ISystem"%>
<%@ page import="jt.classic.system.user.IUser"%>
<%
	String context = jt.classic.system.ISystem.getContextPath();

	IUser user = ISystem.getSessionUser(request);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>新建幻灯片新闻</title>
</head>
<jsp:include page="../head.jsp"></jsp:include>
<link href="<%=context %>/app/info/css/dragcontainer.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="<%=context%>/app/info/css/directree.css" />
<script type="text/javascript" src="<%=context%>/app/info/js/lanmuselect.js"></script>
<script>
   function handleFile(thizz,tp){
      var type = thizz.value.lastIndexOf(".") > 0 ? thizz.value.substring(thizz.value.lastIndexOf(".") + 1,thizz.value.length):"";
      tp.value = type;
   }
   
   var c = 0;
   
   function handleAdd(){
       var o = document.getElementById("DragContainer1");
       
       var bindObject = document.createElement("div");
	   bindObject.id = "div_" + c;
	   bindObject.setAttribute("_id",c);
	   bindObject.className = "DragBox";
	   bindObject.style.cssText = "margin-left:15px;";
	   
	   var str = "内容信息<input type=\"text\" style=\"width:150px;\" name=\"afname_"+c+"\" class=\"box2\" readonly value=\"\" onclick=\"javascript:selinfo('"+c+"');\">";
	   str += "<input type=\"hidden\" id=\"afid_"+c+"\" name=\"afid_"+c+"\" value=\"\">";
	   str += "&nbsp;幻灯显示图片 <input type=\"file\" name=\"file1_"+c+"\" value=\"\">";
	   str += "&nbsp;<a href=\"javascript:handleRemove('div_"+c+"');\">删除</a>";
	   
	   bindObject.innerHTML = str;
	   
       o.appendChild(bindObject);
       
       CreateDragContainer(o);
       
       c++;
   }
   
   function handleRemove(id){
       document.getElementById(id).removeNode(true);
   }
   
   function selinfo(c){
       afid = D("afid_" + c);
       afname = D("afname_" + c);
       
       selectinfolist();
   }
   
   var afname;
   var afid;
   
   function setinfo(id,name){
       afid.value = id;
       afname.value = name;
       
       Ext.getCmp('infoListWin').close();
   }

   function handleSubmit(){
      if(isblank(document.form1.asname)){
         alert("请定义图片新闻名称");
      }else if(isblank(document.form1.askey)){
         alert("请定义图片新闻KEY");
      }else{
           var o = document.getElementById("DragContainer1");
       
	       var parts = o.getElementsByTagName("div");
	       
	       if(parts.length == 0){
	          alert("请定义图片新闻项");
	       }else{
	          var rnt = true;
	          var countP = "";
	          for(var i=0;i<parts.length;i++){
		          var _id = parts[i].getAttribute("_id");
		          if(isblank(document.getElementById("afid_" + _id))){
		             alert("请选择图片显示新闻");
		             rnt = false;
		             break;
		          }else{
		             createHidden("afsort_" + _id,i);
		             countP += _id + ",";
		          }
	          }
	          
	          if(rnt && confirm("确定提交")){
	             createHidden("countP",countP.substring(0,countP.length - 1));
	             
	                Ext.MessageBox.wait('提交保存过程中...');   
				    Ext.Ajax.request({       
				        //请求地址       
				       url: context + "/app/info.do?method=saveslideinfo",       
				       //提交参数组       
				       fileUpload: true,   
				       form: 'form1',   
				       scope: 'form1',     
				       //成功时回调       
				       success: function(response, options) {       
				           //获取响应的json字符串        
				           Ext.MessageBox.hide();
				           
				           var json = response.responseText;    
		                   var o = Ext.util.JSON.decode(json);
				           
				           if (o.success) {
							   alert("提交保存成功！");
							   document.location = context + '/app/info.do?method=slidelistinfo';
		                   }else{
				               Ext.Msg.alert('提示', '提交保存失败！'); 
				           }                
				       }      
				     }); 
	          }
	       }
      }
   }
</script>
<script src="<%=context%>/app/info/js/dragcontainer.js"></script>
<script src="<%=context%>/app/info/js/slideinfo.js"></script>
<body onload="init(0);">
<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="idparent" value=""> <input
	type="hidden" name="userid" value="<%=user.id()%>"> <input
	type="hidden" name="username" value="<%=user.iname()%>"> <input
	type="hidden" name="createtime" value="<%=DateTrimmer.getYMDHMS()%>">
<input type="hidden" id="qdirec" name="qdirec" value=""/>
<input type="hidden" id="qdirecid" name="qdirecid" value=""/>
<input type="hidden" id="qname" name="qname" value=""/>
<input type="hidden" id="qstatus" name="qstatus" value="1"/>
<input type="hidden" id="qdate" name="qdate" value=""/>	
<div style="margin-left:15px;margin-top:15px;">
<input type="button" class="button0"
					value="增加幻灯新闻" onclick="handleAdd();"> <input type="button"
					class="button0" value="提交" onclick="handleSubmit();">
</div>
<fieldset id="lanmu" style="width:90%;margin-left:15px;">
<legend>图片新闻 - 新建图片新闻</legend>
<label for="asname">幻灯片名称</label>
<input type="text" id="asname" name="asname" style="width:400px;" value="" /> <font color="red" title="必填项"><b>*</b></font>
<br/>
<label for="slidetype">幻灯类型</label>
<input type="text" id="slidetype" name="slidetype" style="width:400px;" value="" />
<br/>			
<label for="slidetype">标识key</label>
<input type="text" class="box3" name="askey" style="width:400px;" value="" /> <font color="red" title="必填项"><b>*</b></font>
<br/>
</fieldset>
<div id="Demo4">
<div class="DragContainer" id="DragContainer1" overClass="OverDragContainer"></div>
</div>
</form>
</body>
</html>
